/*
 * mempack - Memory data pack and unpack library
 * author	: calvin
 * email	: calvinwilliams@163.com
 *
 * Licensed under the LGPL v2.1, see the file LICENSE in base directory.
 */

#ifndef _H_MEMPACK_
#define _H_MEMPACK_

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <inttypes.h>
#include <arpa/inet.h>

#include "abuf.h"
#include "hton64.h"

ssize_t MemPack_uint8_to_1byte( uint8_t i , struct AppendBuffer *buf );
ssize_t MemPack_uint16_to_2byte( uint16_t i , struct AppendBuffer *buf );
ssize_t MemPack_uint32_to_4byte( uint32_t i , struct AppendBuffer *buf );
ssize_t MemPack_uint64_to_8byte( uint64_t i , struct AppendBuffer *buf );
ssize_t MemPack_uint32_to_4byte_nobyteorder( uint32_t i , struct AppendBuffer *buf );
ssize_t MemPack_charpt_to_nbyte( char *p , size_t n , struct AppendBuffer *buf );

ssize_t MemUnpack_1byte_to_uint8( struct AppendBuffer *buf , uint8_t *i );
ssize_t MemUnpack_2byte_to_uint16( struct AppendBuffer *buf , uint16_t *i );
ssize_t MemUnpack_4byte_to_uint32( struct AppendBuffer *buf , uint32_t *i );
ssize_t MemUnpack_8byte_to_uint64( struct AppendBuffer *buf , uint64_t *i );
ssize_t MemUnpack_4byte_to_uint32_nobyteorder( struct AppendBuffer *buf , uint32_t *i );
ssize_t MemUnpack_nbyte_to_charpt( struct AppendBuffer *buf , size_t n , char **p );

#ifdef __cplusplus
}
#endif

#endif

